ShardingSphere-JDBC读写分离
sharding-jdbc会通过sql语句进行语义分析,如果是insert、update、delete语句会路由到master库进行操作,如果是select语句会路由到slave库进行操作
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
| spring: application: name: sharding-jdbc-test shardingsphere: datasource: names: m0,s0 m0: type: com.alibaba.druid.pool.DruidDataSource driver-class-name: com.mysql.jdbc.Driver url: jdbc:mysql://localhost:3306/mybatis?useSSL=false username: root password: 123456 s0: type: com.alibaba.druid.pool.DruidDataSource driver-class-name: com.mysql.jdbc.Driver url: jdbc:mysql://localhost:3306/mybatis1?useSSL=false username: root password: 123456
masterslave: name: ms master-data-source-name: m0 slave-data-source-names: s0 load-balance-algorithm-type: round_robin props: sql: show: true
|